/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package database;

// <editor-fold defaultstate="collapsed" desc="HeaderFiles">
import java.sql.Connection;
import java.sql.Statement;// </editor-fold>

/**
 *
 * @author Rajeeb Saha
 */
public class DAO {

    // <editor-fold defaultstate="collapsed" desc="Private Variables">
    private Connection conn = null;
    private Statement sqlStatement;
    private AdministratorDAO adm = new AdministratorDAO(conn, sqlStatement);
    private ClerkDAO clerkDAO = new ClerkDAO(conn, sqlStatement);
    private CustomerDAO customerDAO = new CustomerDAO(conn, sqlStatement);
    private StoreDAO storeDAO = new StoreDAO(conn, sqlStatement);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructor">
    /**
     *
     */
    public DAO() {
        ConnectionDAO connectionDAO = new ConnectionDAO();
        conn = connectionDAO.getConn();
        sqlStatement = connectionDAO.getSqlStatement();
    }// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Aministrator Functionality">
    /**
     *
     * @param password
     * @param firstName
     * @param lastName
     * @return
     */
    protected String addAdministrator(String password, String firstName,
            String lastName) {

        return adm.registerAdministrator(password, firstName, lastName);
    }

    /**
     *
     * @param adminid
     * @return
     */
    protected boolean deleteAdministrator(int adminid) {
        return adm.deleteAdministrator(adminid);
    }

    /**
     *
     * @param adminid
     * @return
     */
    protected String getAdminPassword(int adminid) {
        return adm.getPassword(adminid);
    }

    /**
     *
     * @param adminid
     * @param password
     * @param firstName
     * @param lastName
     * @return
     */
    protected boolean updateAdministrator(int adminid, String password,
            String firstName, String lastName) {
        return adm.updateAdministrator(adminid, password, firstName, lastName);
    }// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Clerk  Functionality">
    /**
     *
     * @param password
     * @param firstName
     * @param lastName
     * @return
     */
    protected String addClerk(String password, String firstName,
            String lastName) {
        return clerkDAO.registerClerk(password, firstName, lastName);
    }

    /**
     *
     * @param ckid
     * @return
     */
    protected boolean deleteClerk(int ckid) {
        return clerkDAO.deleteClerk(ckid);
    }

    /**
     *
     * @param ckid
     * @return
     */
    protected String getClerkPassword(int ckid) {
        return clerkDAO.getPassword(ckid);
    }

    /**
     *
     * @param ckid
     * @param password
     * @param firstName
     * @param lastName
     * @return
     */
    protected boolean updateClerk(int ckid, String password, String firstName,
            String lastName) {
        return clerkDAO.updateClerk(ckid, password, firstName, lastName);
    }// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Store  Functionality">
    /**
     *                        need to add address
     * @param storeName
     * @param phone
     * @param taxCode
     * @param aid
     * @return
     */
    protected boolean addStore(String storeName, String phone, String taxCode,
            String aid) {
        return storeDAO.addStore(storeName, phone, taxCode, aid);
    }

    /**
     *
     * @param storeName
     * @return
     */
    protected boolean deleteStore(String storeName) {
        return storeDAO.deleteStore(storeName);
    }

    /**
     *                    need to add address
     * @param storeName
     * @param phone
     * @param taxCode
     * @param aid
     * @return
     */
    protected boolean updateStore(String storeName, String phone, String taxCode,
            String aid) {
        return storeDAO.updateStore(storeName, phone, taxCode, aid);
    }// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Customer Functionality">
    /**
     *
     * @param password
     * @param firstName
     * @param lastName
     * @param email
     * @param phone
     * @return
     */
    protected String addCustomer(String password, String firstName,
            String lastName, String email, String phone) {
        return customerDAO.registerCustomer(password, firstName, lastName, email,
                phone);
    }

    /**
     *
     * @param csid
     * @return
     */
    protected boolean deleteCustomer(int csid) {
        return customerDAO.deleteCustomer(csid);
    }

    /**
     *
     * @param csid
     * @return
     */
    protected String getCustomerPassword(int csid) {
        return customerDAO.getPassword(csid);
    }

    /**
     *
     * @param csid
     * @param password
     * @param firstName
     * @param lastName
     * @param email
     * @param phone
     * @return
     */
    protected boolean updateCustomer(int csid, String password, String firstName,
            String lastName, String email, String phone) {
        return customerDAO.updateCustomer(csid, password, firstName, lastName,
                email, phone);
    }// </editor-fold>

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
//        System.out.println("rajeeb is a very fine man. well done on figuring out "
//                + " netbeans and svn!");
//        System.out.println("tejinder is able to connect,netbeans is cool");
//        System.out.println("I love this team ; Shaowei");
//        System.out.println("i don't like adeshir!!");


        //     ConnectionDAO c = new ConnectionDAO();

        ClerkDAO clerkDAO = new ClerkDAO();

        //   System.out.println(clerkDAO.addClerk("asdf", "Rajeeb", "Saha"));
        System.out.println(clerkDAO.updateClerk(1000001, "asdfg", "Raj", "Saha"));
    }
}
